package fun.formoji.commons.model;

import lombok.Getter;

/**
 * <code>BusinessException</code>
 * <desc>
 * 描述：
 * <desc/>
 * <b>Creation Time:</b> 2022/8/13 11:51.
 *
 * @author hshe
 */
@Getter
public abstract class BusinessException extends RuntimeException {
    private static final long serialVersionUID = -8866224640593830271L;

    private int code;
    private String msg;
    private ServiceCode serviceCode;

    public BusinessException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public BusinessException(ServiceCode serviceCode) {
        super(serviceCode.getMsg());
        this.code = serviceCode.getCode();
        this.msg = serviceCode.getMsg();
        this.serviceCode = serviceCode;
    }

    public BusinessException(ServiceCode serviceCode, String msg) {
        super(msg);
        this.code = serviceCode.getCode();
        this.msg = msg;
        this.serviceCode = serviceCode;
    }

    public BusinessException(ServiceCode serviceCode, String msg, Throwable cause) {
        super(msg, cause);
        this.code = serviceCode.getCode();
        this.msg = msg;
        this.serviceCode = serviceCode;
    }

    public BusinessException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }


    public BusinessException(String msg, Throwable cause) {
        super(msg, cause);
        this.msg = msg;
    }

    public BusinessException(int code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code;
        this.msg = msg;
    }
}
